package com.ruoyi.workorder.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.workorder.domain.WorkordersContactImage;
import com.ruoyi.workorder.service.IWorkordersContactImageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工作联系单-图片Controller
 * 
 * @author ruoyi
 * @date 2024-07-26
 */
@RestController
@RequestMapping("/workorder/image")
public class WorkordersContactImageController extends BaseController
{
    @Autowired
    private IWorkordersContactImageService workordersContactImageService;

    /**
     * 查询工作联系单-图片列表
     */
    @PreAuthorize("@ss.hasPermi('workorder:image:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkordersContactImage workordersContactImage)
    {
        startPage();
        List<WorkordersContactImage> list = workordersContactImageService.selectWorkordersContactImageList(workordersContactImage);
        return getDataTable(list);
    }

    /**
     * 导出工作联系单-图片列表
     */
    @PreAuthorize("@ss.hasPermi('workorder:image:export')")
    @Log(title = "工作联系单-图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkordersContactImage workordersContactImage)
    {
        List<WorkordersContactImage> list = workordersContactImageService.selectWorkordersContactImageList(workordersContactImage);
        ExcelUtil<WorkordersContactImage> util = new ExcelUtil<WorkordersContactImage>(WorkordersContactImage.class);
        util.exportExcel(response, list, "工作联系单-图片数据");
    }

    /**
     * 获取工作联系单-图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('workorder:image:query')")
    @GetMapping(value = "/{woImageId}")
    public AjaxResult getInfo(@PathVariable("woImageId") Long woImageId)
    {
        return success(workordersContactImageService.selectWorkordersContactImageByWoImageId(woImageId));
    }

    /**
     * 新增工作联系单-图片
     */
    @PreAuthorize("@ss.hasPermi('workorder:image:add')")
    @Log(title = "工作联系单-图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkordersContactImage workordersContactImage)
    {
        return toAjax(workordersContactImageService.insertWorkordersContactImage(workordersContactImage));
    }

    /**
     * 修改工作联系单-图片
     */
    @PreAuthorize("@ss.hasPermi('workorder:image:edit')")
    @Log(title = "工作联系单-图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkordersContactImage workordersContactImage)
    {
        return toAjax(workordersContactImageService.updateWorkordersContactImage(workordersContactImage));
    }

    /**
     * 删除工作联系单-图片
     */
    @PreAuthorize("@ss.hasPermi('workorder:image:remove')")
    @Log(title = "工作联系单-图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{woImageIds}")
    public AjaxResult remove(@PathVariable Long[] woImageIds)
    {
        return toAjax(workordersContactImageService.deleteWorkordersContactImageByWoImageIds(woImageIds));
    }
}
